package com.aya.server;

import com.aya.tb.CodeProcessor;
import com.aya.tb.MappingProxy;
import com.aya.tb.ProcessorResolver;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@Scope("prototype")
public class MvcChannelInboundHandler extends  SimpleChannelInboundHandler<byte[]>  {

    @Resource
    ProcessorResolver processorResolver;
    @Resource
    MappingProxy mappingProxy;
    protected void channelRead0(ChannelHandlerContext ctx, byte[] msg) throws Exception {
        CodeProcessor processor = processorResolver.resolve(msg);
        mappingProxy.execute(processor,ctx);
    }

}
